package com.qdaily.ui.net.model;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;

/**
 * 文章json每一个节点。
 * Created with IntelliJ IDEA.
 * User: Felix
 * Date: 3/30/15
 * Time: 15:19
 * QQ:74104
 * Email:lovejiuwei@gmail.com
 */
public class ArticleMeta implements Parcelable {
    public ArticleMeta() {
    }

    private ArticleFeedPost post;
    private ArrayList<String> designs = new ArrayList<>();
    private AuthorFeed author = new AuthorFeed();
    private ArticleCover cover = new ArticleCover();
    private String image = "";
    private int type = 1;

    public ArticleFeedPost getPost() {
        return post;
    }

    public void setPost(ArticleFeedPost post) {
        this.post = post;
    }

    public ArrayList<String> getDesigns() {
        return designs;
    }

    public void setDesigns(ArrayList<String> designs) {
        this.designs = designs;
    }

    public AuthorFeed getAuthor() {
        return author;
    }

    public void setAuthor(AuthorFeed author) {
        this.author = author;
    }

    public ArticleCover getCover() {
        return cover;
    }

    public void setCover(ArticleCover cover) {
        this.cover = cover;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }


    @Override
    public String toString() {
        return "ArticleMeta{" +
                "post=" + post +
                ", designs=" + designs +
                ", author=" + author +
                ", cover=" + cover +
                ", image='" + image + '\'' +
                ", type=" + type +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.post, 0);
        dest.writeSerializable(this.designs);
        dest.writeParcelable(this.author, 0);
        dest.writeParcelable(this.cover, 0);
        dest.writeString(this.image);
        dest.writeInt(this.type);
    }

    private ArticleMeta(Parcel in) {
        this.post = in.readParcelable(ArticleFeedPost.class.getClassLoader());
        this.designs = (ArrayList<String>) in.readSerializable();
        this.author = in.readParcelable(AuthorFeed.class.getClassLoader());
        this.cover = in.readParcelable(ArticleCover.class.getClassLoader());
        this.image = in.readString();
        this.type = in.readInt();
    }

    public static final Creator<ArticleMeta> CREATOR = new Creator<ArticleMeta>() {
        public ArticleMeta createFromParcel(Parcel source) {
            return new ArticleMeta(source);
        }

        public ArticleMeta[] newArray(int size) {
            return new ArticleMeta[size];
        }
    };
}
